package cn.hsw.component.data;

import cn.hsw.component.core.base.BaseConstant;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {

    /*@Autowired
    AuthService authService;*/

    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createTime", Date.class, DateUtil.date());
        this.strictInsertFill(metaObject, "lastUpdateTime", Date.class, DateUtil.date());
        /*Long currUserPid = null;
        try{
            currUserPid = authService.getCurrUserPid();
        }catch (Exception e){

        }
        this.strictInsertFill(metaObject, "createBy", Long.class, currUserPid);
        this.strictInsertFill(metaObject, "updateBy", Long.class, currUserPid);*/
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "lastUpdateTime", Date.class, DateUtil.date());
        /*Long currUserPid = null;
        try{
            currUserPid = authService.getCurrUserPid();
        }catch (Exception e){

        }
        this.strictInsertFill(metaObject, "updateBy", Long.class, currUserPid);*/
    }
}
